<?php
class models_tintuc extends connect{
	
	function _listtintuc()
	{
		$sql = 'SELECT MaTin, NoiDung FROM tintuc';
		$this-> query_db($sql);
		return $this->fetchAll();
	}
	
	function _addtintuc($NoiDung)
	{
		$sql = "INSERT INTO tintuc VALUES ('','$NoiDung')";
		$this->query_db($sql);
	}
	function _delTinTuc($id){
		$sql = "
				DELETE 
				FROM tintuc
				WHERE MaTin = '$id'";
		$this->query_db($sql);
	}
	function _getTinTuc($id){
		$sql = "
				SELECT MaTin, NoiDung
				FROM tintuc
				WHERE MaTin = '$id'";
		$this->query_db($sql);
		return $this->fetchOne();
	}
	function _updateTinTuc($NoiDung,$id){
		$sql = "UPDATE tintuc
				SET NoiDung = '$NoiDung'
				WHERE MaTin = '$id'";
		$this->query_db($sql);
	}
}
?>